import { sql } from "drizzle-orm";
import { text, real, sqliteTable } from "drizzle-orm/sqlite-core";

export const sites = sqliteTable('sites', {
  id: text('id').primaryKey(),
  name: text('name').notNull(),
  contractAmount: real('contract_amount').notNull(),
  status: text('status', { enum: ['active', 'completed', 'paused'] }).notNull(),
  createdAt: text('created_at').default(sql`CURRENT_TIMESTAMP`),
});

export const expenses = sqliteTable('expenses', {
  id: text('id').primaryKey(),
  siteId: text('site_id')
    .notNull()
    .references(() => sites.id, { onDelete: 'cascade' }),
  type: text('type', { enum: ['material', 'labor', 'equipment', 'other'] }).notNull(),
  amount: real('amount').notNull(),
  description: text('description'),
  paymentDate: text('payment_date').notNull(),
  vendor: text('vendor'),
}); 